
<template>
  <div class="cate-content">
    <div class="item" v-for="(v,i) in subcategory " :key="i">
      <a :href="v.link">
        <img :src="v.image" @load='imgLoad' alt="">
        <div class="item-title">{{v.title}}</div>
      </a>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    subcategory: {
      type: Array,
      default() {
        return []
      }
    }
  },
  data() {
    return {
      count: 0
    }
  },
  methods: {
    imgLoad() {
      if (++this.count === this.subcategory.length) {
        this.count = 0
        this.$emit('imgLoad')
      }
    }
  }
}
</script>

<style scoped>
.cate-content {
  display: flex;
  flex-wrap: wrap;
  padding: 20px 10px 50px;
  font-size: 14px;
}
.item {
  width: 33.33%;
  margin-bottom: 15px;
  color: #333;
  text-align: center;
}
.item img {
  width: 60%;
  margin-bottom: 5px;
}
</style>
